<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"movie0125.gitee.io","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="LFS学习笔记（五）安装基本的系统软件，本章前面部分操作在 root 用户下执行，后面全部进入 chroot 环境下执行。">
<meta property="og:type" content="article">
<meta property="og:title" content="lfs-notebook-05">
<meta property="og:url" content="https://movie0125.gitee.io/2021/05/19/lfs-notebook-05/index.html">
<meta property="og:site_name" content="Movie Blog">
<meta property="og:description" content="LFS学习笔记（五）安装基本的系统软件，本章前面部分操作在 root 用户下执行，后面全部进入 chroot 环境下执行。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-05-19T06:46:54.000Z">
<meta property="article:modified_time" content="2021-06-08T08:06:06.944Z">
<meta property="article:author" content="Movie">
<meta property="article:tag" content="LFS">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://movie0125.gitee.io/2021/05/19/lfs-notebook-05/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>lfs-notebook-05 | Movie Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Movie Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">拥抱开源，快乐分享</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://movie0125.gitee.io/2021/05/19/lfs-notebook-05/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="Movie">
      <meta itemprop="description" content="学习，记录，分享，收获">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Movie Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          lfs-notebook-05
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-19 14:46:54" itemprop="dateCreated datePublished" datetime="2021-05-19T14:46:54+08:00">2021-05-19</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-06-08 16:06:06" itemprop="dateModified" datetime="2021-06-08T16:06:06+08:00">2021-06-08</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">学习笔记</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/19/lfs-notebook-05/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/19/lfs-notebook-05/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="LFS学习笔记（五）"><a href="#LFS学习笔记（五）" class="headerlink" title="LFS学习笔记（五）"></a>LFS学习笔记（五）</h1><p>安装基本的系统软件，本章前面部分操作在 <code>root</code> 用户下执行，后面全部进入 <code>chroot</code> 环境下执行。</p>
<a id="more"></a>

<h2 id="挂载虚拟文件系统"><a href="#挂载虚拟文件系统" class="headerlink" title="挂载虚拟文件系统"></a>挂载虚拟文件系统</h2><p>内核会挂载几个文件系统用于自己和用户空间程序交换信息。这些文件系统是虚拟的，并不占用实际磁盘空间，它们的内容会放在内存里。</p>
<p>开始先创建将用来挂载文件系统的目录： </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> <span class="variable">$LFS</span></span><br><span class="line"><span class="comment">#我的环境上有两个备份目录，将他们转移到宿主机目录中去。</span></span><br><span class="line">mv sources.back tools.back /data/</span><br><span class="line"></span><br><span class="line">mkdir -pv <span class="variable">$LFS</span>/&#123;dev,proc,sys,run&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#创建初始设备节点</span></span><br><span class="line">mknod -m 600 <span class="variable">$LFS</span>/dev/console c 5 1</span><br><span class="line">mknod -m 666 <span class="variable">$LFS</span>/dev/null c 1 3</span><br><span class="line"></span><br><span class="line"><span class="comment"># 挂载和激活 /dev</span></span><br><span class="line">mount -v --<span class="built_in">bind</span> /dev <span class="variable">$LFS</span>/dev</span><br><span class="line"></span><br><span class="line"><span class="comment">#挂载剩下的虚拟内核文件系统：</span></span><br><span class="line">mount -vt devpts devpts <span class="variable">$LFS</span>/dev/pts -o gid=5,mode=620</span><br><span class="line">mount -vt proc proc <span class="variable">$LFS</span>/proc</span><br><span class="line">mount -vt sysfs sysfs <span class="variable">$LFS</span>/sys</span><br><span class="line">mount -vt tmpfs tmpfs <span class="variable">$LFS</span>/run</span><br><span class="line"></span><br><span class="line"><span class="comment">#在某些宿主机系统里，/dev/shm 是一个指向 /run/shm 的符号链接。这个 /run 下的 tmpfs 文件系统已经在之前挂载了，所以在这里只需要创建一个目录。</span></span><br><span class="line"><span class="keyword">if</span> [ -h <span class="variable">$LFS</span>/dev/shm ]; <span class="keyword">then</span></span><br><span class="line">  mkdir -pv <span class="variable">$LFS</span>/$(readlink <span class="variable">$LFS</span>/dev/shm)</span><br><span class="line"><span class="keyword">fi</span></span><br></pre></td></tr></table></figure>
<h2 id="软件包管理"><a href="#软件包管理" class="headerlink" title="软件包管理"></a>软件包管理</h2><p>软件包管理经常被请求加入到 LFS 手册中。软件包管理器可以追踪安装的文件，方便软件包的移除和升级。不仅是二进制执行文件和库文件，包管理器还会处理配置文件的安装。在你想太多之前，答案是不——本节不讨论也不安利任何特定的软件包管理器，只是总结了一下关于软件包管理的常用技术和工作原理。对你而言最完美的软件包管理器可能就在这些技术之中，也可能由这些技术的其中几个组合而成。本节还简要的提了一些在升级软件包时可能遇到的问题。</p>
<p>为什么 LFS 或 BLFS 手册里不采用任何软件包管理器的一些原因：</p>
<ul>
<li>使用软件包管理偏离了本手册的主要目标——教大家 Linux 系统是如何构建出来的。</li>
<li>存在很多软件包管理的解决方案，每一个都有自己的长处和缺点。很难选择一种适合所有人的方式。</li>
</ul>
<p>关于软件包管理有很多资料，可以访问 <a target="_blank" rel="noopener" href="https://www.linuxfromscratch.org/hints/list.html">Hints Project</a> 看看是否可以解决你的需求。<br>这里介绍了一些<a target="_blank" rel="noopener" href="https://lctt.github.io/LFS-BOOK/lfs-systemd/chapter06/pkgmgt.html">软件包管理的方向</a>。</p>
<h2 id="进入-chroot-环境"><a href="#进入-chroot-环境" class="headerlink" title="进入 chroot 环境"></a>进入 chroot 环境</h2><pre><code>之后的所有命令都是进入 `chroot` 执行</code></pre>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">chroot <span class="string">&quot;<span class="variable">$LFS</span>&quot;</span> /tools/bin/env -i \</span><br><span class="line">    HOME=/root                  \</span><br><span class="line">    TERM=<span class="string">&quot;<span class="variable">$TERM</span>&quot;</span>                \</span><br><span class="line">    PS1=<span class="string">&#x27;(lfs chroot) \u:\w\$ &#x27;</span> \</span><br><span class="line">    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \</span><br><span class="line">    /tools/bin/bash --login +h</span><br></pre></td></tr></table></figure>

<h2 id="创建目录"><a href="#创建目录" class="headerlink" title="创建目录"></a>创建目录</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">mkdir -pv /&#123;bin,boot,etc/&#123;opt,sysconfig&#125;,home,lib/firmware,mnt,opt&#125;</span><br><span class="line">mkdir -pv /&#123;media/&#123;floppy,cdrom&#125;,sbin,srv,var&#125;</span><br><span class="line">install -dv -m 0750 /root</span><br><span class="line">install -dv -m 1777 /tmp /var/tmp</span><br><span class="line">mkdir -pv /usr/&#123;,<span class="built_in">local</span>/&#125;&#123;bin,include,lib,sbin,src&#125;</span><br><span class="line">mkdir -pv /usr/&#123;,<span class="built_in">local</span>/&#125;share/&#123;color,dict,doc,info,locale,man&#125;</span><br><span class="line">mkdir -v  /usr/&#123;,<span class="built_in">local</span>/&#125;share/&#123;misc,terminfo,zoneinfo&#125;</span><br><span class="line">mkdir -v  /usr/libexec</span><br><span class="line">mkdir -pv /usr/&#123;,<span class="built_in">local</span>/&#125;share/man/man&#123;1..8&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">case</span> $(uname -m) <span class="keyword">in</span></span><br><span class="line"> x86_64) mkdir -v /lib64 ;;</span><br><span class="line"><span class="keyword">esac</span></span><br><span class="line"></span><br><span class="line">mkdir -v /var/&#123;<span class="built_in">log</span>,mail,spool&#125;</span><br><span class="line">ln -sv /run /var/run</span><br><span class="line">ln -sv /run/lock /var/lock</span><br><span class="line">mkdir -pv /var/&#123;opt,cache,lib/&#123;color,misc,locate&#125;,<span class="built_in">local</span>&#125;</span><br></pre></td></tr></table></figure>
<h2 id="创建必要的文件和符号链接"><a href="#创建必要的文件和符号链接" class="headerlink" title="创建必要的文件和符号链接"></a>创建必要的文件和符号链接</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br></pre></td><td class="code"><pre><span class="line">ln -sv /tools/bin/&#123;bash,cat,chmod,dd,<span class="built_in">echo</span>,ln,mkdir,<span class="built_in">pwd</span>,rm,stty,touch&#125; /bin</span><br><span class="line">ln -sv /tools/bin/&#123;env,install,perl,<span class="built_in">printf</span>&#125;         /usr/bin</span><br><span class="line">ln -sv /tools/lib/libgcc_s.so&#123;,.1&#125;                  /usr/lib</span><br><span class="line">ln -sv /tools/lib/libstdc++.&#123;a,so&#123;,.6&#125;&#125;             /usr/lib</span><br><span class="line"></span><br><span class="line">ln -sv bash /bin/sh</span><br><span class="line"></span><br><span class="line"><span class="comment">#由于历史原因，Linux 在文件 /etc/mtab 中维护一个已挂载文件系统的列表。而现代内核改为在内部维护这个列表，并通过 /proc 文件系统输出给用户。为了满足一些依赖 /etc/mtab 文件的应用程序，我们要创建下面的符号链接：\</span></span><br><span class="line">ln -sv /proc/self/mounts /etc/mtab</span><br><span class="line"></span><br><span class="line"><span class="comment">#为了让 root 用户能正常登录，而且「root」的名字能被正常识别，必须在文件 /etc/passwd 和 /etc/group 中写入相应的内容。</span></span><br><span class="line">cat &gt; /etc/passwd &lt;&lt; <span class="string">&quot;EOF&quot;</span></span><br><span class="line">root:x:0:0:root:/root:/bin/bash</span><br><span class="line">bin:x:1:1:bin:/dev/null:/bin/<span class="literal">false</span></span><br><span class="line">daemon:x:6:6:Daemon User:/dev/null:/bin/<span class="literal">false</span></span><br><span class="line">messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/<span class="literal">false</span></span><br><span class="line">systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/<span class="literal">false</span></span><br><span class="line">systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/<span class="literal">false</span></span><br><span class="line">systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/<span class="literal">false</span></span><br><span class="line">systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/<span class="literal">false</span></span><br><span class="line">systemd-network:x:76:76:systemd Network Management:/:/bin/<span class="literal">false</span></span><br><span class="line">systemd-resolve:x:77:77:systemd Resolver:/:/bin/<span class="literal">false</span></span><br><span class="line">systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/<span class="literal">false</span></span><br><span class="line">systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/<span class="literal">false</span></span><br><span class="line">nobody:x:99:99:Unprivileged User:/dev/null:/bin/<span class="literal">false</span></span><br><span class="line">EOF</span><br><span class="line"></span><br><span class="line">cat &gt; /etc/group &lt;&lt; <span class="string">&quot;EOF&quot;</span></span><br><span class="line">root:x:0:</span><br><span class="line">bin:x:1:daemon</span><br><span class="line">sys:x:2:</span><br><span class="line">kmem:x:3:</span><br><span class="line">tape:x:4:</span><br><span class="line">tty:x:5:</span><br><span class="line">daemon:x:6:</span><br><span class="line">floppy:x:7:</span><br><span class="line">disk:x:8:</span><br><span class="line">lp:x:9:</span><br><span class="line">dialout:x:10:</span><br><span class="line">audio:x:11:</span><br><span class="line">video:x:12:</span><br><span class="line">utmp:x:13:</span><br><span class="line">usb:x:14:</span><br><span class="line">cdrom:x:15:</span><br><span class="line">adm:x:16:</span><br><span class="line">messagebus:x:18:</span><br><span class="line">systemd-journal:x:23:</span><br><span class="line">input:x:24:</span><br><span class="line">mail:x:34:</span><br><span class="line">kvm:x:61:</span><br><span class="line">systemd-bus-proxy:x:72:</span><br><span class="line">systemd-journal-gateway:x:73:</span><br><span class="line">systemd-journal-remote:x:74:</span><br><span class="line">systemd-journal-upload:x:75:</span><br><span class="line">systemd-network:x:76:</span><br><span class="line">systemd-resolve:x:77:</span><br><span class="line">systemd-timesync:x:78:</span><br><span class="line">systemd-coredump:x:79:</span><br><span class="line">wheel:x:97:</span><br><span class="line">nogroup:x:99:</span><br><span class="line">users:x:999:</span><br><span class="line">EOF</span><br><span class="line"></span><br><span class="line"><span class="comment">#为了移除「I have no name!」的提示符，可以打开一个新 shell,重新执行 chroot命令。</span></span><br><span class="line"><span class="built_in">exit</span></span><br><span class="line">chroot <span class="string">&quot;<span class="variable">$LFS</span>&quot;</span> /tools/bin/env -i \</span><br><span class="line">    HOME=/root                  \</span><br><span class="line">    TERM=<span class="string">&quot;<span class="variable">$TERM</span>&quot;</span>                \</span><br><span class="line">    PS1=<span class="string">&#x27;(lfs chroot) \u:\w\$ &#x27;</span> \</span><br><span class="line">    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \</span><br><span class="line">    /tools/bin/bash --login +h</span><br><span class="line"></span><br><span class="line"><span class="comment">#程序 login、agetty 和 init（还有一些其它的）会使用一些日志文件来记录信息，比如谁在什么时候登录了系统。不过，在日志文件不存在的时候这些程序一般不会写入。</span></span><br><span class="line"><span class="comment">#文件 /var/log/wtmp 会记录所有的登录和登出动作。文件 /var/log/lastlog 会记录每个用户的最后一次登录时间。文件 /var/log/faillog 会记录失败的登录尝试。文件 /var/log/btmp 会记录非法的登录尝试。文件 /run/utmp 会记录当前已登录的用户，这个文件会在启动脚本中动态创建。</span></span><br><span class="line">touch /var/<span class="built_in">log</span>/&#123;btmp,lastlog,faillog,wtmp&#125;</span><br><span class="line">chgrp -v utmp /var/<span class="built_in">log</span>/lastlog</span><br><span class="line">chmod -v 664  /var/<span class="built_in">log</span>/lastlog</span><br><span class="line">chmod -v 600  /var/<span class="built_in">log</span>/btmp</span><br></pre></td></tr></table></figure>
<h2 id="安装Linux-5-2-8-API-头文件"><a href="#安装Linux-5-2-8-API-头文件" class="headerlink" title="安装Linux-5.2.8 API 头文件"></a>安装Linux-5.2.8 API 头文件</h2><p>进入chroot环境操作</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build/linux-5.2.8</span><br><span class="line"></span><br><span class="line"><span class="comment">#编译前清理</span></span><br><span class="line">make mrproper</span><br><span class="line"></span><br><span class="line">make INSTALL_HDR_PATH=dest headers_install</span><br><span class="line">find dest/include \( -name .install -o -name ..install.cmd \) -delete</span><br><span class="line">cp -rv dest/include/* /usr/include</span><br></pre></td></tr></table></figure>
<h2 id="安装-Man-pages-5-02"><a href="#安装-Man-pages-5-02" class="headerlink" title="安装 Man-pages-5.02"></a>安装 Man-pages-5.02</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build/</span><br><span class="line">tar xf ../man-pages-5.02.tar.xz</span><br><span class="line"><span class="built_in">cd</span> man-pages-5.02/</span><br><span class="line"></span><br><span class="line">make install </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="安装-Glibc-2-30"><a href="#安装-Glibc-2-30" class="headerlink" title="安装 Glibc-2.30"></a>安装 Glibc-2.30</h2><p>Glibc 软件包包含了主要的 C 函数库。这个库提供了分配内存、搜索目录、打开关闭文件、读写文件、操作字符串、模式匹配、基础算法等基本程序。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build/glibc-2.30</span><br><span class="line"></span><br><span class="line"><span class="comment">#有些 Glibc 程序会用到和 FHS 不兼容的 /var/db 目录来存储它们的运行时数据。打上如下的补丁让这些程序在 FHS 兼容的位置存储它们的运行时数据。</span></span><br><span class="line">patch -Np1 -i ../../glibc-2.30-fhs-1.patch</span><br><span class="line"></span><br><span class="line"><span class="comment">#修复 linux-5.2 内核引入的问题：</span></span><br><span class="line"></span><br><span class="line">sed -i <span class="string">&#x27;/asm.socket.h/a# include &lt;linux/sockios.h&gt;&#x27;</span> \</span><br><span class="line">   sysdeps/unix/sysv/linux/bits/socket.h</span><br><span class="line"></span><br><span class="line"><span class="comment">#顺应 LSB 规范创建一个符号链接。此外，x86_64 情况下，为了使动态加载器正确运作，再创建一个兼容性的符号链接：</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">case</span> $(uname -m) <span class="keyword">in</span></span><br><span class="line">    i?86)   ln -sfv ld-linux.so.2 /lib/ld-lsb.so.3</span><br><span class="line">    ;;</span><br><span class="line">    x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64</span><br><span class="line">            ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3</span><br><span class="line">    ;;</span><br><span class="line"><span class="keyword">esac</span></span><br><span class="line"></span><br><span class="line">mkdir -v build</span><br><span class="line"><span class="built_in">cd</span> build</span><br><span class="line"></span><br><span class="line">CC=<span class="string">&quot;gcc -ffile-prefix-map=/tools=/usr&quot;</span> \</span><br><span class="line">../configure --prefix=/usr                          \</span><br><span class="line">             --disable-werror                       \</span><br><span class="line">             --enable-kernel=3.2                    \</span><br><span class="line">             --enable-stack-protector=strong        \</span><br><span class="line">             --with-headers=/usr/include            \</span><br><span class="line">             libc_cv_slibdir=/lib</span><br><span class="line"></span><br><span class="line"><span class="comment">#编译</span></span><br><span class="line">make </span><br><span class="line"></span><br><span class="line"><span class="keyword">case</span> $(uname -m) <span class="keyword">in</span></span><br><span class="line">  i?86)   ln -sfnv <span class="variable">$PWD</span>/elf/ld-linux.so.2        /lib ;;</span><br><span class="line">  x86_64) ln -sfnv <span class="variable">$PWD</span>/elf/ld-linux-x86-64.so.2 /lib ;;</span><br><span class="line"><span class="keyword">esac</span></span><br><span class="line"></span><br><span class="line">make check</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>你可能会看到一些失败的测试项。Glibc 的测试套件对宿主系统有一定的依赖。下面是一些 LFS 版本中最常见的问题：</p>
<ul>
<li>misc/tst-ttyname 已知会在 LFS 的 chroot 环境中失败。</li>
<li>inet/tst-idna_name_classify 已知会在 LFS 的 chroot 环境中失败。</li>
<li>posix/tst-getaddrinfo4 和 posix/tst-getaddrinfo5 可能在某些架构上失败。</li>
<li>nss/tst-nss-files-hosts-multi 由于未知的原因，测试可能失败。</li>
<li>rt/tst-cputimer{1,2,3} 测试取决于宿主机的系统内核。众所周知，内核版本 4.14.91–4.14.96、4.19.13–4.19.18 和 4.20.0–4.20.5 是会导致这些测试失败的。</li>
<li>如果你系统的 CPU 不是相对较新的 Intel 或 AMD 处理器，数学运算测试有时候会失败。</li>
</ul>
<p>在安装 Glibc 时会报告找不到 /etc/ld.so.conf 文件。下面的方式可以避免这个警告：<code>touch /etc/ld.so.conf</code></p>
<p>修复生成的 Makefile 以跳过一个没有必要的完整性检查，该检查在部分 LFS 环境中会失败：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">sed <span class="string">&#x27;/test-installation/s@$(PERL)@echo not running@&#x27;</span> -i ../Makefile</span><br><span class="line"></span><br><span class="line">make install </span><br><span class="line"></span><br><span class="line"><span class="comment">#为 nscd 安装配置文件并创建运行时目录：</span></span><br><span class="line">cp -v ../nscd/nscd.conf /etc/nscd.conf</span><br><span class="line">mkdir -pv /var/cache/nscd</span><br><span class="line"></span><br><span class="line"><span class="comment">#为 nscd 安装系统支持文件：</span></span><br><span class="line">install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf</span><br><span class="line">install -v -Dm644 ../nscd/nscd.service /lib/systemd/system/nscd.service</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>


<p>接着，安装可以使系统响应不同语言的地域设置。没有一个地域是必需的，但是如果缺少了其中的某些，可能会导致在未来的软件包测试套件中，跳过了重要的测试项目。</p>
<p>单独的语言环境可以用 localedef 程序安装。例如，下面第一个 localedef 命令将 /usr/share/i18n/locales/cs_CZ 字符表定义组合在一起，并将结果附加到 /usr/share/i18n/charmaps/UTF-8.gz 文件末尾。下面的命令将安装能完美覆盖测试所需语言环境的最小集合：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">mkdir -pv /usr/lib/locale</span><br><span class="line">localedef -i POSIX -f UTF-8 C.UTF-8 2&gt; /dev/null || <span class="literal">true</span></span><br><span class="line">localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8</span><br><span class="line">localedef -i de_DE -f ISO-8859-1 de_DE</span><br><span class="line">localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro</span><br><span class="line">localedef -i de_DE -f UTF-8 de_DE.UTF-8</span><br><span class="line">localedef -i el_GR -f ISO-8859-7 el_GR</span><br><span class="line">localedef -i en_GB -f UTF-8 en_GB.UTF-8</span><br><span class="line">localedef -i en_HK -f ISO-8859-1 en_HK</span><br><span class="line">localedef -i en_PH -f ISO-8859-1 en_PH</span><br><span class="line">localedef -i en_US -f ISO-8859-1 en_US</span><br><span class="line">localedef -i en_US -f UTF-8 en_US.UTF-8</span><br><span class="line">localedef -i es_MX -f ISO-8859-1 es_MX</span><br><span class="line">localedef -i fa_IR -f UTF-8 fa_IR</span><br><span class="line">localedef -i fr_FR -f ISO-8859-1 fr_FR</span><br><span class="line">localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro</span><br><span class="line">localedef -i fr_FR -f UTF-8 fr_FR.UTF-8</span><br><span class="line">localedef -i it_IT -f ISO-8859-1 it_IT</span><br><span class="line">localedef -i it_IT -f UTF-8 it_IT.UTF-8</span><br><span class="line">localedef -i ja_JP -f EUC-JP ja_JP</span><br><span class="line">localedef -i ja_JP -f SHIFT_JIS ja_JP.SIJS 2&gt; /dev/null || <span class="literal">true</span></span><br><span class="line">localedef -i ja_JP -f UTF-8 ja_JP.UTF-8</span><br><span class="line">localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R</span><br><span class="line">localedef -i ru_RU -f UTF-8 ru_RU.UTF-8</span><br><span class="line">localedef -i tr_TR -f UTF-8 tr_TR.UTF-8</span><br><span class="line">localedef -i zh_CN -f GB18030 zh_CN.GB18030</span><br><span class="line">localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">make localedata/install-locales</span><br></pre></td></tr></table></figure>
<h3 id="配置-Glibc"><a href="#配置-Glibc" class="headerlink" title="配置 Glibc"></a>配置 Glibc</h3><p>由于 Glibc 的默认状态在网络环境下工作的并不好，所以需要创建 /etc/nsswitch.conf 文件。</p>
<p>创建新的 /etc/nsswitch.conf 通过以下命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">cat &gt; /etc/nsswitch.conf &lt;&lt; <span class="string">&quot;EOF&quot;</span></span><br><span class="line"><span class="comment"># Begin /etc/nsswitch.conf</span></span><br><span class="line"></span><br><span class="line">passwd: files</span><br><span class="line">group: files</span><br><span class="line">shadow: files</span><br><span class="line"></span><br><span class="line">hosts: files dns</span><br><span class="line">networks: files</span><br><span class="line"></span><br><span class="line">protocols: files</span><br><span class="line">services: files</span><br><span class="line">ethers: files</span><br><span class="line">rpc: files</span><br><span class="line"></span><br><span class="line"><span class="comment"># End /etc/nsswitch.conf</span></span><br><span class="line">EOF</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h3 id="添加时区数据"><a href="#添加时区数据" class="headerlink" title="添加时区数据"></a>添加时区数据</h3><p>通过以下命令安装并启动时区数据：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar -xf ../tzdata2019b.tar.gz</span><br><span class="line"></span><br><span class="line">ZONEINFO=/usr/share/zoneinfo</span><br><span class="line">mkdir -pv <span class="variable">$ZONEINFO</span>/&#123;posix,right&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> tz <span class="keyword">in</span> etcetera southamerica northamerica europe africa antarctica  \</span><br><span class="line">          asia australasia backward pacificnew systemv; <span class="keyword">do</span></span><br><span class="line">    zic -L /dev/null   -d <span class="variable">$ZONEINFO</span>       <span class="variable">$&#123;tz&#125;</span></span><br><span class="line">    zic -L /dev/null   -d <span class="variable">$ZONEINFO</span>/posix <span class="variable">$&#123;tz&#125;</span></span><br><span class="line">    zic -L leapseconds -d <span class="variable">$ZONEINFO</span>/right <span class="variable">$&#123;tz&#125;</span></span><br><span class="line"><span class="keyword">done</span></span><br><span class="line"></span><br><span class="line">cp -v zone.tab zone1970.tab iso3166.tab <span class="variable">$ZONEINFO</span></span><br><span class="line">zic -d <span class="variable">$ZONEINFO</span> -p America/New_York</span><br><span class="line"><span class="built_in">unset</span> ZONEINFO</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">tzselect</span><br><span class="line"></span><br><span class="line">ln -sfv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h3 id="配置动态库加载器"><a href="#配置动态库加载器" class="headerlink" title="配置动态库加载器"></a>配置动态库加载器</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">cat &gt; /etc/ld.so.conf &lt;&lt; <span class="string">&quot;EOF&quot;</span></span><br><span class="line"><span class="comment"># Begin /etc/ld.so.conf</span></span><br><span class="line">/usr/<span class="built_in">local</span>/lib</span><br><span class="line">/opt/lib</span><br><span class="line"></span><br><span class="line">EOF</span><br><span class="line"></span><br><span class="line">cat &gt;&gt; /etc/ld.so.conf &lt;&lt; <span class="string">&quot;EOF&quot;</span></span><br><span class="line"><span class="comment"># Add an include directory</span></span><br><span class="line">include /etc/ld.so.conf.d/*.conf</span><br><span class="line"></span><br><span class="line">EOF</span><br><span class="line">mkdir -pv /etc/ld.so.conf.d</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="调整工具链"><a href="#调整工具链" class="headerlink" title="调整工具链"></a>调整工具链</h2><p>现在最后的 C 语言库已经装好了，是时候调整工具链，让新编译的程序链接到这些新的库上。<br>首先，备份 /tools 链接器，然后用我们在第五章调整过的链接器代替它。我们还会创建一个链接，链接到 /tools/$(uname -m)-pc-linux-gnu/bin 的副本：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line">mv -v /tools/bin/&#123;ld,ld-old&#125;</span><br><span class="line">mv -v /tools/$(uname -m)-pc-linux-gnu/bin/&#123;ld,ld-old&#125;</span><br><span class="line">mv -v /tools/bin/&#123;ld-new,ld&#125;</span><br><span class="line">ln -sv /tools/bin/ld /tools/$(uname -m)-pc-linux-gnu/bin/ld</span><br><span class="line"></span><br><span class="line"><span class="comment">#修改 GCC 参数文件，让它指向新的动态连接器。只需删除所有「/tools」的实例，这样应该可以留下到达动态链接器的正确路径。还要调整参数文件，这样 GCC 就知道怎样找到正确的头文件和 Glibc 启动文件</span></span><br><span class="line">gcc -dumpspecs | sed -e <span class="string">&#x27;s@/tools@@g&#x27;</span>                   \</span><br><span class="line">    -e <span class="string">&#x27;/\*startfile_prefix_spec:/&#123;n;s@.*@/usr/lib/ @&#125;&#x27;</span> \</span><br><span class="line">    -e <span class="string">&#x27;/\*cpp:/&#123;n;s@$@ -isystem /usr/include@&#125;&#x27;</span> &gt;      \</span><br><span class="line">    `dirname $(gcc --print-libgcc-file-name)`/specs</span><br><span class="line"></span><br><span class="line"><span class="comment">#一个简单的编译测试工作</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">&#x27;int main()&#123;&#125;&#x27;</span> &gt; dummy.c</span><br><span class="line">cc dummy.c -v -Wl,--verbose &amp;&gt; dummy.log</span><br><span class="line">readelf -l a.out | grep <span class="string">&#x27;: /lib&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#确保我们已经设置好了启动文件：</span></span><br><span class="line">grep -o <span class="string">&#x27;/usr/lib.*/crt[1in].*succeeded&#x27;</span> dummy.log</span><br><span class="line"><span class="comment">#命令的输出应该是：</span></span><br><span class="line"><span class="comment">#/usr/lib/../lib/crt1.o succeeded</span></span><br><span class="line"><span class="comment">#/usr/lib/../lib/crti.o succeeded</span></span><br><span class="line"><span class="comment">#/usr/lib/../lib/crtn.o succeeded</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#确保链接器能找到正确的头文件：</span></span><br><span class="line">grep -B1 <span class="string">&#x27;^ /usr/include&#x27;</span> dummy.log</span><br><span class="line"><span class="comment">#命令应该返回如下输出：</span></span><br><span class="line"><span class="comment">#include &lt;...&gt; search starts here:</span></span><br><span class="line"><span class="comment"># /usr/include</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#确认新的链接器已经在使用正确的搜索路径：</span></span><br><span class="line">grep <span class="string">&#x27;SEARCH.*/usr/lib&#x27;</span> dummy.log |sed <span class="string">&#x27;s|; |\n|g&#x27;</span></span><br><span class="line"><span class="comment">#忽略指向带有 &#x27;-linux-gnu&#x27; 的路径，命令的输出应该是：</span></span><br><span class="line"><span class="comment">#SEARCH_DIR(&quot;/usr/lib&quot;)</span></span><br><span class="line"><span class="comment">#SEARCH_DIR(&quot;/lib&quot;)</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#确定我们使用的是正确的 libc：</span></span><br><span class="line">grep <span class="string">&quot;/lib.*/libc.so.6 &quot;</span> dummy.log</span><br><span class="line"><span class="comment">#命令的输出应该为：</span></span><br><span class="line"><span class="comment">#attempt to open /lib/libc.so.6 succeeded</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#确保 GCC 使用的是正确的动态链接器：</span></span><br><span class="line">grep found dummy.log</span><br><span class="line"><span class="comment">#命令的结果应该是（不同的平台上链接器名字可以不同）：</span></span><br><span class="line"><span class="comment">#found ld-linux-x86-64.so.2 at /lib/ld-linux-x86-64.so.2</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#清理测试文件</span></span><br><span class="line">rm -v dummy.c a.out dummy.log</span><br></pre></td></tr></table></figure>
<h2 id="安装-Zlib-1-2-11"><a href="#安装-Zlib-1-2-11" class="headerlink" title="安装 Zlib-1.2.11"></a>安装 Zlib-1.2.11</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../zlib-1.2.11.tar.xz</span><br><span class="line"><span class="built_in">cd</span> zlib-1.2.11/</span><br><span class="line">./configure --prefix=/usr</span><br><span class="line">make</span><br><span class="line">make check</span><br><span class="line">make install</span><br><span class="line"></span><br><span class="line"><span class="comment">#共享库需要移动到 /lib，因此需要重建 .so 里面的 /usr/lib 文件：</span></span><br><span class="line">mv -v /usr/lib/libz.so.* /lib</span><br><span class="line">ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so</span><br></pre></td></tr></table></figure>
<h2 id="安装-File-5-37"><a href="#安装-File-5-37" class="headerlink" title="安装 File-5.37"></a>安装 File-5.37</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../file-5.37.tar.gz</span><br><span class="line"><span class="built_in">cd</span> file-5.37</span><br><span class="line">./configure --prefix=/usr</span><br><span class="line">make</span><br><span class="line">make check</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h2 id="Readline-8-0"><a href="#Readline-8-0" class="headerlink" title="Readline-8.0"></a>Readline-8.0</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../readline-8.0.tar.gz</span><br><span class="line"><span class="built_in">cd</span> readline-8.0/</span><br><span class="line"></span><br><span class="line">sed -i <span class="string">&#x27;/MV.*old/d&#x27;</span> Makefile.in</span><br><span class="line">sed -i <span class="string">&#x27;/&#123;OLDSUFF&#125;/c:&#x27;</span> support/shlib-install</span><br><span class="line">./configure --prefix=/usr    \</span><br><span class="line">            --disable-static \</span><br><span class="line">            --docdir=/usr/share/doc/readline-8.0</span><br><span class="line"></span><br><span class="line">make SHLIB_LIBS=<span class="string">&quot;-L/tools/lib -lncursesw&quot;</span></span><br><span class="line">make SHLIB_LIBS=<span class="string">&quot;-L/tools/lib -lncursesw&quot;</span> install</span><br><span class="line"></span><br><span class="line">mv -v /usr/lib/lib&#123;readline,<span class="built_in">history</span>&#125;.so.* /lib</span><br><span class="line">chmod -v u+w /lib/lib&#123;readline,<span class="built_in">history</span>&#125;.so.*</span><br><span class="line">ln -sfv ../../lib/$(readlink /usr/lib/libreadline.so) /usr/lib/libreadline.so</span><br><span class="line">ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so</span><br><span class="line"></span><br><span class="line">install -v -m644 doc/*.&#123;ps,pdf,html,dvi&#125; /usr/share/doc/readline-8.0</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="安装-M4-1-4-18"><a href="#安装-M4-1-4-18" class="headerlink" title="安装 M4-1.4.18"></a>安装 M4-1.4.18</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../m4-1.4.18.tar.xz</span><br><span class="line"><span class="built_in">cd</span> m4-1.4.18/</span><br><span class="line"></span><br><span class="line"><span class="comment">#对 glibc-2.28 的需求做一些修复：</span></span><br><span class="line">sed -i <span class="string">&#x27;s/IO_ftrylockfile/IO_EOF_SEEN/&#x27;</span> lib/*.c</span><br><span class="line"><span class="built_in">echo</span> <span class="string">&quot;#define _IO_IN_BACKUP 0x100&quot;</span> &gt;&gt; lib/stdio-impl.h</span><br><span class="line"></span><br><span class="line">./configure --prefix=/usr</span><br><span class="line">make</span><br><span class="line">make check</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h2 id="安装-Bc-2-1-3"><a href="#安装-Bc-2-1-3" class="headerlink" title="安装 Bc-2.1.3"></a>安装 Bc-2.1.3</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../bc-2.1.3.tar.gz</span><br><span class="line"><span class="built_in">cd</span> bc-2.1.3/</span><br><span class="line"></span><br><span class="line">PREFIX=/usr CC=gcc CFLAGS=<span class="string">&quot;-std=c99&quot;</span> ./configure.sh -G -O3</span><br><span class="line">make </span><br><span class="line">make <span class="built_in">test</span> </span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h2 id="安装-Binutils-2-32"><a href="#安装-Binutils-2-32" class="headerlink" title="安装 Binutils-2.32"></a>安装 Binutils-2.32</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../binutils-2.32.tar.xz</span><br><span class="line"><span class="built_in">cd</span> binutils-2.32/</span><br><span class="line"></span><br><span class="line">expect -c <span class="string">&quot;spawn ls&quot;</span></span><br><span class="line"><span class="comment">#命令应该输出以下内容：</span></span><br><span class="line"><span class="comment">#spawn ls</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#删除一项测试，以保证不会影响到测试的完成：</span></span><br><span class="line">sed -i <span class="string">&#x27;/@\tincremental_copy/d&#x27;</span> gold/testsuite/Makefile.in</span><br><span class="line"></span><br><span class="line">mkdir -v build</span><br><span class="line"><span class="built_in">cd</span>       build</span><br><span class="line"></span><br><span class="line">../configure --prefix=/usr       \</span><br><span class="line">             --enable-gold       \</span><br><span class="line">             --enable-ld=default \</span><br><span class="line">             --enable-plugins    \</span><br><span class="line">             --enable-shared     \</span><br><span class="line">             --disable-werror    \</span><br><span class="line">             --enable-64-bit-bfd \</span><br><span class="line">             --with-system-zlib</span><br><span class="line"></span><br><span class="line">make tooldir=/usr</span><br><span class="line">make -k check</span><br><span class="line">make tooldir=/usr install</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="安装-GMP-6-1-2"><a href="#安装-GMP-6-1-2" class="headerlink" title="安装 GMP-6.1.2"></a>安装 GMP-6.1.2</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../gmp-6.1.2.tar.xz</span><br><span class="line"><span class="built_in">cd</span> gmp-6.1.2/</span><br><span class="line"></span><br><span class="line">./configure --prefix=/usr    \</span><br><span class="line">            --enable-cxx     \</span><br><span class="line">            --disable-static \</span><br><span class="line">            --docdir=/usr/share/doc/gmp-6.1.2</span><br><span class="line">make</span><br><span class="line">make html</span><br><span class="line">make check 2&gt;&amp;1 | tee gmp-check-log</span><br><span class="line">awk <span class="string">&#x27;/# PASS:/&#123;total+=$3&#125; ; END&#123;print total&#125;&#x27;</span> gmp-check-log</span><br><span class="line">make install</span><br><span class="line">make install-html</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="安装-MPFR-4-0-2"><a href="#安装-MPFR-4-0-2" class="headerlink" title="安装 MPFR-4.0.2"></a>安装 MPFR-4.0.2</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../mpfr-4.0.2.tar.xz</span><br><span class="line"><span class="built_in">cd</span> mpfr-4.0.2/</span><br><span class="line"></span><br><span class="line">./configure --prefix=/usr        \</span><br><span class="line">            --disable-static     \</span><br><span class="line">            --enable-thread-safe \</span><br><span class="line">            --docdir=/usr/share/doc/mpfr-4.0.2</span><br><span class="line">make</span><br><span class="line">make html</span><br><span class="line">make check</span><br><span class="line">make install</span><br><span class="line">make install-html</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="安装-MPC-1-1-0"><a href="#安装-MPC-1-1-0" class="headerlink" title="安装 MPC-1.1.0"></a>安装 MPC-1.1.0</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../mpc-1.1.0.tar.gz</span><br><span class="line"><span class="built_in">cd</span> mpc-1.1.0/</span><br><span class="line"></span><br><span class="line">./configure --prefix=/usr    \</span><br><span class="line">            --disable-static \</span><br><span class="line">            --docdir=/usr/share/doc/mpc-1.1.0</span><br><span class="line"></span><br><span class="line">make</span><br><span class="line">make html</span><br><span class="line">make check</span><br><span class="line">make install</span><br><span class="line">make install-html</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="安装-Shadow-4-7"><a href="#安装-Shadow-4-7" class="headerlink" title="安装 Shadow-4.7"></a>安装 Shadow-4.7</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /sources/build</span><br><span class="line">tar xf ../shadow-4.7.tar.xz</span><br><span class="line"><span class="built_in">cd</span> shadow-4.7/</span><br><span class="line"></span><br><span class="line">sed -i <span class="string">&#x27;s/groups$(EXEEXT) //&#x27;</span> src/Makefile.in</span><br><span class="line">find man -name Makefile.in -<span class="built_in">exec</span> sed -i <span class="string">&#x27;s/groups\.1 / /&#x27;</span>   &#123;&#125; \;</span><br><span class="line">find man -name Makefile.in -<span class="built_in">exec</span> sed -i <span class="string">&#x27;s/getspnam\.3 / /&#x27;</span> &#123;&#125; \;</span><br><span class="line">find man -name Makefile.in -<span class="built_in">exec</span> sed -i <span class="string">&#x27;s/passwd\.5 / /&#x27;</span>   &#123;&#125; \;</span><br><span class="line"></span><br><span class="line">sed -i -e <span class="string">&#x27;s@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@&#x27;</span> \</span><br><span class="line">       -e <span class="string">&#x27;s@/var/spool/mail@/var/mail@&#x27;</span> etc/login.defs</span><br><span class="line"></span><br><span class="line">sed -i <span class="string">&#x27;s@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@&#x27;</span> etc/login.defs</span><br><span class="line"></span><br><span class="line">sed -i <span class="string">&#x27;s/1000/999/&#x27;</span> etc/useradd</span><br><span class="line">./configure --sysconfdir=/etc --with-group-name-max-length=32</span><br><span class="line"></span><br><span class="line">make</span><br><span class="line">make install </span><br><span class="line">mv -v /usr/bin/passwd /bin</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h3 id="配置-Shadow"><a href="#配置-Shadow" class="headerlink" title="配置 Shadow"></a>配置 Shadow</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#运行下面的命令启用 shadow 密码：</span></span><br><span class="line">pwconv</span><br><span class="line"></span><br><span class="line"><span class="comment">#运行下面的命令启用 shadow 组密码：</span></span><br><span class="line">grpconv</span><br><span class="line"></span><br><span class="line"><span class="comment">#设置 root 密码</span></span><br><span class="line">passwd root</span><br></pre></td></tr></table></figure>
    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/LFS/" rel="tag"># LFS</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/05/18/lfs-notebook-04/" rel="prev" title="lfs-notebook-04">
      <i class="fa fa-chevron-left"></i> lfs-notebook-04
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/05/20/lfs-notebook-06/" rel="next" title="lfs-notebook-06">
      lfs-notebook-06 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#LFS%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%EF%BC%88%E4%BA%94%EF%BC%89"><span class="nav-number">1.</span> <span class="nav-text">LFS学习笔记（五）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8C%82%E8%BD%BD%E8%99%9A%E6%8B%9F%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-number">1.1.</span> <span class="nav-text">挂载虚拟文件系统</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%BD%AF%E4%BB%B6%E5%8C%85%E7%AE%A1%E7%90%86"><span class="nav-number">1.2.</span> <span class="nav-text">软件包管理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%BF%9B%E5%85%A5-chroot-%E7%8E%AF%E5%A2%83"><span class="nav-number">1.3.</span> <span class="nav-text">进入 chroot 环境</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%9B%E5%BB%BA%E7%9B%AE%E5%BD%95"><span class="nav-number">1.4.</span> <span class="nav-text">创建目录</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%9B%E5%BB%BA%E5%BF%85%E8%A6%81%E7%9A%84%E6%96%87%E4%BB%B6%E5%92%8C%E7%AC%A6%E5%8F%B7%E9%93%BE%E6%8E%A5"><span class="nav-number">1.5.</span> <span class="nav-text">创建必要的文件和符号链接</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85Linux-5-2-8-API-%E5%A4%B4%E6%96%87%E4%BB%B6"><span class="nav-number">1.6.</span> <span class="nav-text">安装Linux-5.2.8 API 头文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-Man-pages-5-02"><span class="nav-number">1.7.</span> <span class="nav-text">安装 Man-pages-5.02</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-Glibc-2-30"><span class="nav-number">1.8.</span> <span class="nav-text">安装 Glibc-2.30</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE-Glibc"><span class="nav-number">1.8.1.</span> <span class="nav-text">配置 Glibc</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B7%BB%E5%8A%A0%E6%97%B6%E5%8C%BA%E6%95%B0%E6%8D%AE"><span class="nav-number">1.8.2.</span> <span class="nav-text">添加时区数据</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE%E5%8A%A8%E6%80%81%E5%BA%93%E5%8A%A0%E8%BD%BD%E5%99%A8"><span class="nav-number">1.8.3.</span> <span class="nav-text">配置动态库加载器</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B0%83%E6%95%B4%E5%B7%A5%E5%85%B7%E9%93%BE"><span class="nav-number">1.9.</span> <span class="nav-text">调整工具链</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-Zlib-1-2-11"><span class="nav-number">1.10.</span> <span class="nav-text">安装 Zlib-1.2.11</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-File-5-37"><span class="nav-number">1.11.</span> <span class="nav-text">安装 File-5.37</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Readline-8-0"><span class="nav-number">1.12.</span> <span class="nav-text">Readline-8.0</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-M4-1-4-18"><span class="nav-number">1.13.</span> <span class="nav-text">安装 M4-1.4.18</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-Bc-2-1-3"><span class="nav-number">1.14.</span> <span class="nav-text">安装 Bc-2.1.3</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-Binutils-2-32"><span class="nav-number">1.15.</span> <span class="nav-text">安装 Binutils-2.32</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-GMP-6-1-2"><span class="nav-number">1.16.</span> <span class="nav-text">安装 GMP-6.1.2</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-MPFR-4-0-2"><span class="nav-number">1.17.</span> <span class="nav-text">安装 MPFR-4.0.2</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-MPC-1-1-0"><span class="nav-number">1.18.</span> <span class="nav-text">安装 MPC-1.1.0</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-Shadow-4-7"><span class="nav-number">1.19.</span> <span class="nav-text">安装 Shadow-4.7</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE-Shadow"><span class="nav-number">1.19.1.</span> <span class="nav-text">配置 Shadow</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">Movie</p>
  <div class="site-description" itemprop="description">学习，记录，分享，收获</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">14</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Movie</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>











<script>
if (document.querySelectorAll('pre.mermaid').length) {
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js', () => {
    mermaid.initialize({
      theme    : 'forest',
      logLevel : 3,
      flowchart: { curve     : 'linear' },
      gantt    : { axisFormat: '%m/%d/%Y' },
      sequence : { actorMargin: 50 }
    });
  }, window.mermaid);
}
</script>


  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'bx3R5BB7VYCe0Yu5f4PF2Ako-gzGzoHsz',
      appKey     : '24eOkgM1v8hYTlnAO3C2eG3n',
      placeholder: "欢迎留言评论",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : 'zh-cn' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
